package server.util.panel;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
import server.display.ClientRemoteDesktop;

public class ClientRemoteDesktopPanel extends JPanel {

    private BufferedImage image;
    
    private ClientRemoteDesktop clientRemoteDesktop;
    
    public void setClientRemoteDesktop(ClientRemoteDesktop clientRemoteDesktop) {
        this.clientRemoteDesktop = clientRemoteDesktop;
    }
        
    public void updateImage(BufferedImage image) {
        this.image = image;
        
        Dimension size = new Dimension(image.getWidth(), image.getHeight());
        setPreferredSize(size);
        clientRemoteDesktop.pack();
        
        repaint();
    }
    
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        g.drawImage(image, 0, 0, this);
    }
    
}
